package com.example.score.common;

import org.apache.commons.lang3.ObjectUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class RateConstants {


    /**
     * 默认保留两位小数
     */
    public static final int DEFAULT_SCALE = 4;

    /**
     * 保留两位小数
     */
    public static final int TOW_SCALE = 2;

    /**
     * 百分号
     */
    public static final String PER_CENT = "%";

    /**
     * 100
     */
    public static final BigDecimal ONE_HUNDRED = new BigDecimal("100");

    /**
     * 优秀占比阈值
     */
    public static final BigDecimal EXCELLENT = new BigDecimal("0.85");

    /**
     * 良好占比阈值
     */
    public static final BigDecimal GOOD = new BigDecimal("0.70");

    /**
     * 及格占比阈值
     */
    public static final BigDecimal PASS = new BigDecimal("0.60");

    /**
     * 低分占比阈值
     */
    public static final BigDecimal LOW = new BigDecimal("0.40");

    /**
     * 乘以100计算
     *
     * @param number
     * @return
     */
    public static String multiplyOneHundred(BigDecimal number) {
        if (ObjectUtils.isEmpty(number)) {
            return BigDecimal.ZERO.toString();
        }
        return number.multiply(ONE_HUNDRED).setScale(TOW_SCALE, RoundingMode.HALF_UP) + PER_CENT;
    }
}
